﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Mvc;
using GWEB.WebBase.Data;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;
using Newtonsoft.Json;

namespace GWEB.WebFrame.Customer
{
    public class ContractEditDateController : PageInfoBase
    {

        [ActionFilter(IsLogin = true)]
        public ActionResult Index(String id, String keyCode)
        {
            return Load("ContractEditDate", "Customer/ContractEditDate", id, keyCode);
        }
        protected override SqlState SqlExecute(BaseData bd, string id, Dictionary<string, object> data)
        {
            String userId = BasePage.GetUserId(Session);
            string Remark = data["Remark"].ToString();
            data.Remove("Remark");
            data["status"] = "4";
            String[] sqls = new string[2];
            //延时日志
            sqls[0] = String.Format(@"insert into Cu_Contract_Delay(ContractId,OldCourseEnd,NewCourseEnd,CreateId,Remark,CreateDate)
select id, CourseEnd, '{0}', {1},'{3}', getdate() from cu_Contract where id = {2}", Fun.cSql(data["CourseEnd"]), userId, id,Remark);
            sqls[1] = BaseData.MapToSql("cu_Contract", "id", id, data); 
            bool t = bd.ExecuteSQL(sqls,sqls.Length);
            return t ? SqlState.True : SqlState.False;
        }
    }
}